package com.sg.service.biz.framework.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.sg.common.util.CommonFunctionHelper;
import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.framework.req.*;
import com.sg.dto.biz.framework.res.*;
import com.sg.service.base.framework.*;
import com.wicket.okrframework.common.dto.TreeNode;
import com.sg.common.exception.Assert;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class DivineDataServiceImpl implements com.wicket.okrframework.biz.service.DivineDataService {
    @Resource
    private RedisUtil redisUtil;
    @Resource
    private MInductionRecordService mInductionRecordService;
    @Resource
    private NbDivineData nbDivineData;
    @Resource
    private MBizSceneService mBizSceneService;
    @Resource
    private MPrivacyService mPrivacyService;
    @Resource
    private MSceneRoleService mSceneRoleService;
    @Resource
    private MUsersService mUsersService;
    @Resource
    private MDeptService mDeptService;
//@Resource
    //private MCustomFields2Service mCustomFields2Service;
//@Resource
    //private MSpecMethordTableService mSpecMethordTableService;

    /**
     * D查询可用管理部门（特殊方法）[1544]
     * gen by moon at 10/15/2022, 5:39:31 PM
     */
    @Trace(operationName = "D查询可用管理部门（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryDeptCollectionRemoveExistingDataListRespDto queryDeptCollectionRemoveExistingDataList(QueryDeptCollectionRemoveExistingDataListReqDto reqDto) {


        QueryDeptCollectionRemoveExistingDataListRespDto collectionRemoveExistingDataRes_1 = null;
//步骤0: M-查询可用管理部门（特殊方法） - queryDeptCollectionRemoveExistingDataList
        //ModelCode: collectionRemoveExistingData
        QueryDeptCollectionRemoveExistingDataListRespDto collectionRemoveExistingDataRes = null;
        QueryDeptCollectionRemoveExistingDataListReqDto collectionRemoveExistingDataReq = new QueryDeptCollectionRemoveExistingDataListReqDto();
        if (reqDto != null && reqDto.getOrgInductionRecordList() != null && !CollectionUtil.isEmpty(reqDto.getOrgInductionRecordList())) {
            collectionRemoveExistingDataReq.setOrgInductionRecordList(reqDto.getOrgInductionRecordList().stream().map(item -> {
                OrgInductionRecordDto elm = BeanUtil.toBean(item, OrgInductionRecordDto.class);
                //elm.setEntityId();//EXIST_ID  TODO ruizhe dong

                return elm;
            }).collect(Collectors.toList()));//objList-to-objLists//sourceId:43668_1
        }
        if (reqDto != null && reqDto.getManagedDeptList() != null && !CollectionUtil.isEmpty(reqDto.getManagedDeptList())) {
            collectionRemoveExistingDataReq.setManagedDeptList(reqDto.getManagedDeptList().stream().map(item -> {
                ManagedDeptListDto elm = BeanUtil.toBean(item, ManagedDeptListDto.class);
                //elm.setDeptId();//EXIST_ID  TODO ruizhe dong

                return elm;
            }).collect(Collectors.toList()));//objList-to-objLists//sourceId:43669_1
        }

        /*M-查询可用管理部门（特殊方法）[1543]  入参两个数据集，通过已存在标识字段匹配，去除第一个数据集中已存在的第二个数据集的数据 */

        collectionRemoveExistingDataRes = nbDivineData.queryDeptCollectionRemoveExistingDataList(collectionRemoveExistingDataReq);


        collectionRemoveExistingDataRes_1 = collectionRemoveExistingDataRes;

        QueryDeptCollectionRemoveExistingDataListRespDto retData = new QueryDeptCollectionRemoveExistingDataListRespDto();
        if (collectionRemoveExistingDataRes_1 != null) {
            retData.setOrgInductionRecordList(collectionRemoveExistingDataRes_1.getOrgInductionRecordList().stream().map(item -> BeanUtil.toBean(item, OrgInductionRecordDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:43670_1
        }


        return retData;
    }

    /**
     * Redis批量清空用户信息[1713]
     * gen by moon at 10/2/2022, 12:22:20 AM
     */
    @Trace(operationName = "Redis批量清空用户信息")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public BatchClearUserInfoFromRedisRespDto batchClearUserInfoFromRedis(BatchClearUserInfoFromRedisReqDto reqDto) {


        //步骤0: M-Redis批量清空用户信息（特殊方法） - batchClearUserInfoFromRedis
        //ModelCode: clearUserInfoFromRedis
        BatchClearUserInfoFromRedisRespDto clearUserInfoFromRedisRes = null;
        BatchClearUserInfoFromRedisReqDto clearUserInfoFromRedisReq = new BatchClearUserInfoFromRedisReqDto();
        if (reqDto != null) {
            //list-field-assign
            clearUserInfoFromRedisReq.setBeginMemberList(reqDto.getBeginMemberList());//sourceId:51314_1
        }

        /*M-Redis批量清空用户信息（特殊方法）[1695]  清除用户缓存，不用重新登录，通过token重新获取 */

        clearUserInfoFromRedisRes = nbDivineData.batchClearUserInfoFromRedis(clearUserInfoFromRedisReq);


        BatchClearUserInfoFromRedisRespDto retData = new BatchClearUserInfoFromRedisRespDto();


        return retData;
    }

    /**
     * D-Redis清空用户信息[1710]
     * gen by moon at 9/7/2022, 1:37:51 AM
     */
    @Trace(operationName = "D-Redis清空用户信息")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public ClearUserInfoFromRedisRespDto clearUserInfoFromRedis(ClearUserInfoFromRedisReqDto reqDto) {


        //步骤0: M-Redis清空用户信息（特殊方法） - clearUserInfoFromRedis
        //ModelCode: clearUserInfoFromRedis
        ClearUserInfoFromRedisRespDto clearUserInfoFromRedisRes = null;
        ClearUserInfoFromRedisReqDto clearUserInfoFromRedisReq = new ClearUserInfoFromRedisReqDto();
        if (reqDto != null) {
            clearUserInfoFromRedisReq.setOriginalRoleMemberId(reqDto.getOriginalRoleMemberId());//SimpleFieldAssign//sourceId:51182_1
        }

        /*M-Redis清空用户信息（特殊方法）[1673]  清除用户缓存，不用重新登录，通过token重新获取 */

        clearUserInfoFromRedisRes = nbDivineData.clearUserInfoFromRedis(clearUserInfoFromRedisReq);


        ClearUserInfoFromRedisRespDto retData = new ClearUserInfoFromRedisRespDto();


        return retData;
    }

    /**
     * D-Redis清空用户Token(公共)[1698]
     * gen by moon at 10/2/2022, 12:20:50 AM
     */
    @Trace(operationName = "D-Redis清空用户Token(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public ClearTokenFromRedisRespDto clearTokenFromRedis(ClearTokenFromRedisReqDto reqDto) {


        //步骤0: M-Redis清空用户Token（特殊方法） - clearTokenFromRedis
        //ModelCode: clearTokenFromRedis
        ClearTokenFromRedisRespDto clearTokenFromRedisRes = null;
        ClearTokenFromRedisReqDto clearTokenFromRedisReq = new ClearTokenFromRedisReqDto();
        if (reqDto != null) {
            clearTokenFromRedisReq.setOriginalRoleMemberId(reqDto.getOriginalRoleMemberId());//SimpleFieldAssign//sourceId:50542_1
        }

        /*M-Redis清空用户Token（特殊方法）[1696]  入参身份ID，清除用户token */

        clearTokenFromRedisRes = nbDivineData.clearTokenFromRedis(clearTokenFromRedisReq);


        ClearTokenFromRedisRespDto retData = new ClearTokenFromRedisRespDto();


        return retData;
    }

    /**
     * D-Redis批量清空用户Token[1712]
     * gen by moon at 8/10/2022, 3:19:39 AM
     */
    @Trace(operationName = "D-Redis批量清空用户Token")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public BatchClearTokenFromRedisRespDto batchClearTokenFromRedis(BatchClearTokenFromRedisReqDto reqDto) {


        //步骤0: M-Redis批量清空用户Token（特殊方法） - batchClearTokenFromRedis
        //ModelCode: batchClearTokenFromRedis
        BatchClearTokenFromRedisRespDto batchClearTokenFromRedisRes = null;
        BatchClearTokenFromRedisReqDto batchClearTokenFromRedisReq = new BatchClearTokenFromRedisReqDto();
        if (reqDto != null) {
            batchClearTokenFromRedisReq.setBeginMemberList(reqDto.getBeginMemberList());//sourceId:51309_1
        }

        /*M-Redis批量清空用户Token（特殊方法）[1711]  入参身份ID集合，清除用户token */

        batchClearTokenFromRedisRes = nbDivineData.batchClearTokenFromRedis(batchClearTokenFromRedisReq);


        BatchClearTokenFromRedisRespDto retData = new BatchClearTokenFromRedisRespDto();


        return retData;
    }

    /**
     * D-Redis获取用户就职信息[1681]
     * gen by moon at 10/2/2022, 12:19:08 AM
     */
    @Trace(operationName = "D-Redis获取用户就职信息")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public AddGetUserIrInfoFromRedisRespDto addGetUserIrInfoFromRedis(AddGetUserIrInfoFromRedisReqDto reqDto) {


        GetUserIrInfoFromRedisRespDto getUserIrInfoFromRedisRes_1 = null;
//步骤0: M-Redis获取用户就职信息（特殊方法） - getUserIrInfoFromRedis
        //ModelCode: getUserIrInfoFromRedis
        GetUserIrInfoFromRedisRespDto getUserIrInfoFromRedisRes = null;
        GetUserIrInfoFromRedisReqDto getUserIrInfoFromRedisReq = new GetUserIrInfoFromRedisReqDto();
        if (reqDto != null) {
            getUserIrInfoFromRedisReq.setOriginalRoleMemberId(reqDto.getOriginalRoleMemberId());//SimpleFieldAssign//sourceId:49930_1
        }

        /*M-Redis获取用户就职信息（特殊方法）[1678]   */

        getUserIrInfoFromRedisRes = nbDivineData.getUserIrInfoFromRedis(getUserIrInfoFromRedisReq);


        getUserIrInfoFromRedisRes_1 = getUserIrInfoFromRedisRes;

        AddGetUserIrInfoFromRedisRespDto retData = new AddGetUserIrInfoFromRedisRespDto();
        if (getUserIrInfoFromRedisRes_1 != null) {
            retData.setOrgInductionRecordList(getUserIrInfoFromRedisRes_1.getOrgInductionRecordList().stream().map(item -> BeanUtil.toBean(item, OrgInductionRecordDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:49933_1
        }


        return retData;
    }

    /**
     * D-Redis获取用户基本信息[1680]
     * gen by moon at 10/2/2022, 12:18:56 AM
     */
    @Trace(operationName = "D-Redis获取用户基本信息")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public GetUserBasicInfoFromRedisRespDto getUserBasicInfoFromRedis(GetUserBasicInfoFromRedisReqDto reqDto) {


        GetUserBasicInfoFromRedisRespDto getUserBasicInfoFromRedisRes_1 = null;
//步骤0: M-Redis获取用户基本信息（特殊方法） - getUserBasicInfoFromRedis
        //ModelCode: getUserBasicInfoFromRedis
        GetUserBasicInfoFromRedisRespDto getUserBasicInfoFromRedisRes = null;
        GetUserBasicInfoFromRedisReqDto getUserBasicInfoFromRedisReq = new GetUserBasicInfoFromRedisReqDto();
        if (reqDto != null) {
            getUserBasicInfoFromRedisReq.setOriginalRoleMemberId(reqDto.getOriginalRoleMemberId());//SimpleFieldAssign//sourceId:49895_1
        }

        /*M-Redis获取用户基本信息（特殊方法）[1677]   */

        getUserBasicInfoFromRedisRes = nbDivineData.getUserBasicInfoFromRedis(getUserBasicInfoFromRedisReq);

        getUserBasicInfoFromRedisRes_1 = getUserBasicInfoFromRedisRes;

        GetUserBasicInfoFromRedisRespDto retData = new GetUserBasicInfoFromRedisRespDto();
        if (getUserBasicInfoFromRedisRes_1 != null) {
            retData.setUserId(getUserBasicInfoFromRedisRes_1.getUserId());//SimpleFieldAssign//sourceId:49914_1
            retData.setOriginalRoleMemberId(getUserBasicInfoFromRedisRes_1.getOriginalRoleMemberId());//SimpleFieldAssign//sourceId:49915_1
            retData.setMemberId(getUserBasicInfoFromRedisRes_1.getMemberId());//SimpleFieldAssign//sourceId:49916_1
            retData.setUserName(getUserBasicInfoFromRedisRes_1.getUserName());//SimpleFieldAssign//sourceId:49917_1
            retData.setIdCardName(getUserBasicInfoFromRedisRes_1.getIdCardName());//SimpleFieldAssign//sourceId:49918_1
            retData.setNickName(getUserBasicInfoFromRedisRes_1.getNickName());//SimpleFieldAssign//sourceId:49919_1
            retData.setUserFace(getUserBasicInfoFromRedisRes_1.getUserFace());//SimpleFieldAssign//sourceId:49920_1
            retData.setSex(getUserBasicInfoFromRedisRes_1.getSex());//SimpleFieldAssign//sourceId:49921_1
            retData.setBirthday(getUserBasicInfoFromRedisRes_1.getBirthday());//SimpleFieldAssign//sourceId:49922_1
            retData.setCity(getUserBasicInfoFromRedisRes_1.getCity());//SimpleFieldAssign//sourceId:49923_1
            retData.setPhone(getUserBasicInfoFromRedisRes_1.getPhone());//SimpleFieldAssign//sourceId:49924_1
            retData.setPassByPhone(getUserBasicInfoFromRedisRes_1.getPassByPhone());//SimpleFieldAssign//sourceId:49925_1
            retData.setIsUserInfoDone(getUserBasicInfoFromRedisRes_1.getIsUserInfoDone());//SimpleFieldAssign//sourceId:49926_1
            retData.setRoleMemberCode(getUserBasicInfoFromRedisRes_1.getRoleMemberCode());//SimpleFieldAssign//sourceId:49927_1
            retData.setPositionIdName(getUserBasicInfoFromRedisRes_1.getPositionIdName());//SimpleFieldAssign//sourceId:49928_1
            retData.setRoleList(getUserBasicInfoFromRedisRes_1.getRoleList().stream().map(item -> BeanUtil.toBean(item, FrameworkSceneRoleDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:49929_1
        }


        return retData;
    }

    /**
     * Redis获取空间信息[1664]
     * gen by moon at 10/2/2022, 12:18:30 AM
     */
    @Trace(operationName = "Redis获取空间信息")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public GetSpaceInfoFromRedisRespDto getSpaceInfoFromRedis(GetSpaceInfoFromRedisReqDto reqDto) {


        GetSpaceInfoFromRedisRespDto getSpaceInfoFromRedisRes_1 = null;
//步骤0: M-Redis获取空间信息（特殊方法） - getSpaceInfoFromRedis
        //ModelCode: getSpaceInfoFromRedis
        GetSpaceInfoFromRedisRespDto getSpaceInfoFromRedisRes = null;
        GetSpaceInfoFromRedisReqDto getSpaceInfoFromRedisReq = new GetSpaceInfoFromRedisReqDto();
        if (reqDto != null) {
            getSpaceInfoFromRedisReq.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:49399_1
        }
  
    /*M-Redis获取空间信息（特殊方法）[1663]  入参：空间ID
出参：返回缓存中空间ID对应的数据 */

        getSpaceInfoFromRedisRes = nbDivineData.getSpaceInfoFromRedis(getSpaceInfoFromRedisReq);


        getSpaceInfoFromRedisRes_1 = getSpaceInfoFromRedisRes;

        GetSpaceInfoFromRedisRespDto retData = new GetSpaceInfoFromRedisRespDto();
        if (getSpaceInfoFromRedisRes_1 != null) {
            retData.setSpaceId(getSpaceInfoFromRedisRes_1.getSpaceId());//SimpleFieldAssign//sourceId:49426_1
            retData.setSpaceCode(getSpaceInfoFromRedisRes_1.getSpaceCode());//SimpleFieldAssign//sourceId:49427_1
            retData.setSpaceName(getSpaceInfoFromRedisRes_1.getSpaceName());//SimpleFieldAssign//sourceId:49428_1
            retData.setSceneId(getSpaceInfoFromRedisRes_1.getSceneId());//SimpleFieldAssign//sourceId:49429_1
            retData.setSenceCode(getSpaceInfoFromRedisRes_1.getSenceCode());//SimpleFieldAssign//sourceId:49430_1
            retData.setSceneName(getSpaceInfoFromRedisRes_1.getSceneName());//SimpleFieldAssign//sourceId:49431_1
            retData.setAppId(getSpaceInfoFromRedisRes_1.getAppId());//SimpleFieldAssign//sourceId:49432_1
            retData.setAppCode(getSpaceInfoFromRedisRes_1.getAppCode());//SimpleFieldAssign//sourceId:49433_1
            retData.setAppName(getSpaceInfoFromRedisRes_1.getAppName());//SimpleFieldAssign//sourceId:49434_1
            retData.setAppIntroduce(getSpaceInfoFromRedisRes_1.getAppIntroduce());//SimpleFieldAssign//sourceId:49435_1
            retData.setAppUpdateIntroduct(getSpaceInfoFromRedisRes_1.getAppUpdateIntroduct());//SimpleFieldAssign//sourceId:49436_1
            retData.setWebsite(getSpaceInfoFromRedisRes_1.getWebsite());//SimpleFieldAssign//sourceId:49437_1
            retData.setAppLogo(getSpaceInfoFromRedisRes_1.getAppLogo());//SimpleFieldAssign//sourceId:49438_1
            retData.setAboutLogo(getSpaceInfoFromRedisRes_1.getAboutLogo());//SimpleFieldAssign//sourceId:49439_1
            retData.setAppBanner(getSpaceInfoFromRedisRes_1.getAppBanner());//SimpleFieldAssign//sourceId:49440_1
            retData.setServicePhone(getSpaceInfoFromRedisRes_1.getServicePhone());//SimpleFieldAssign//sourceId:49441_1
            retData.setServiceTime(getSpaceInfoFromRedisRes_1.getServiceTime());//SimpleFieldAssign//sourceId:49442_1
            retData.setCopyright(getSpaceInfoFromRedisRes_1.getCopyright());//SimpleFieldAssign//sourceId:49443_1
            retData.setAppVersion(getSpaceInfoFromRedisRes_1.getAppVersion());//SimpleFieldAssign//sourceId:49444_1
            retData.setIsEnableSms(getSpaceInfoFromRedisRes_1.getIsEnableSms());//SimpleFieldAssign//sourceId:49445_1
            retData.setIsUsePlatfomSms(getSpaceInfoFromRedisRes_1.getIsUsePlatfomSms());//SimpleFieldAssign//sourceId:49446_1
            retData.setAccessKeyId(getSpaceInfoFromRedisRes_1.getAccessKeyId());//SimpleFieldAssign//sourceId:49447_1
            retData.setAccessKeySecret(getSpaceInfoFromRedisRes_1.getAccessKeySecret());//SimpleFieldAssign//sourceId:49448_1
            retData.setIsOpenMultiOrg(getSpaceInfoFromRedisRes_1.getIsOpenMultiOrg());//SimpleFieldAssign//sourceId:49449_1
            retData.setOrgList(getSpaceInfoFromRedisRes_1.getOrgList().stream().map(item -> BeanUtil.toBean(item, OrgDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:49450_1
        }


        return retData;
    }

    /**
     * Redis切换公共信息（后端）[1624]
     * gen by moon at 10/2/2022, 12:16:28 AM
     */
    @Trace(operationName = "Redis切换公共信息（后端）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public ChangePublicInfoFromRedisRespDto changePublicInfoFromRedis(ChangePublicInfoFromRedisReqDto reqDto) {


        //步骤0: M-Redis切换公共信息（后端）（特殊方法） - changePublicInfoFromRedis
        //ModelCode: changePublicInfoFromRedis
        ChangePublicInfoFromRedisRespDto changePublicInfoFromRedisRes = null;
        ChangePublicInfoFromRedisReqDto changePublicInfoFromRedisReq = new ChangePublicInfoFromRedisReqDto();
        if (reqDto != null) {
            changePublicInfoFromRedisReq.setInductionRecordId(reqDto.getInductionRecordId());//SimpleFieldAssign//sourceId:47176_1
        }

        /*M-Redis切换公共信息（后端）（特殊方法）[1623]  用于切换用户公共缓存信息，在个人中心面板上切换就职记录时触发 */

        changePublicInfoFromRedisRes = nbDivineData.changePublicInfoFromRedis(changePublicInfoFromRedisReq);


        ChangePublicInfoFromRedisRespDto retData = new ChangePublicInfoFromRedisRespDto();


        return retData;
    }

    /**
     * 异步结束[1620]
     * gen by moon at 10/26/2022, 12:20:47 AM
     */
    @Trace(operationName = "异步结束")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public AsynchronizationEndRespDto asynchronizationEnd(AsynchronizationEndReqDto reqDto) {


        AsynchronizationEndRespDto retData = new AsynchronizationEndRespDto();


        return retData;
    }

    /**
     * 异步开始[1619]
     * gen by moon at 10/26/2022, 12:20:46 AM
     */
    @Trace(operationName = "异步开始")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public AsynchronizationStartRespDto asynchronizationStart(AsynchronizationStartReqDto reqDto) {


        AsynchronizationStartRespDto retData = new AsynchronizationStartRespDto();


        return retData;
    }

    /**
     * D查询过滤后可推荐业务场景列表[1593]
     * gen by moon at 10/28/2022, 8:45:31 PM
     */
    @Trace(operationName = "D查询过滤后可推荐业务场景列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryHostTypeCollectionRemoveExistingDataListRespDto queryHostTypeCollectionRemoveExistingDataList(QueryHostTypeCollectionRemoveExistingDataListReqDto reqDto) {


        QueryHostTypeCollectionRemoveExistingDataListRespDto collectionRemoveExistingDataRes_1 = null;
//步骤0: M-查询过滤后可推荐业务场景列表（特殊方法） - queryHostTypeCollectionRemoveExistingDataList
        //ModelCode: collectionRemoveExistingData
        QueryHostTypeCollectionRemoveExistingDataListRespDto collectionRemoveExistingDataRes = null;
        QueryHostTypeCollectionRemoveExistingDataListReqDto collectionRemoveExistingDataReq = new QueryHostTypeCollectionRemoveExistingDataListReqDto();
        if (reqDto != null && reqDto.getBizSceneList() != null && !CollectionUtil.isEmpty(reqDto.getBizSceneList())) {
            collectionRemoveExistingDataReq.setBizSceneList(reqDto.getBizSceneList().stream().map(item -> BeanUtil.toBean(item, BizSceneDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:46040_1
        }
        if (reqDto != null) {
            collectionRemoveExistingDataReq.setHostTypeBizScnList(reqDto.getHostTypeBizScnList());//list-field-assign//sourceId:46041_1
        }

        /*M-查询过滤后可推荐业务场景列表（特殊方法）[1592]  入参两个数据集，通过已存在标识字段匹配，去除第一个数据集中已存在的第二个数据集的数据 */

        collectionRemoveExistingDataRes = nbDivineData.queryHostTypeCollectionRemoveExistingDataList(collectionRemoveExistingDataReq);


        collectionRemoveExistingDataRes_1 = collectionRemoveExistingDataRes;

        QueryHostTypeCollectionRemoveExistingDataListRespDto retData = new QueryHostTypeCollectionRemoveExistingDataListRespDto();
        if (collectionRemoveExistingDataRes_1 != null) {
            retData.setBizSceneList(collectionRemoveExistingDataRes_1.getBizSceneList().stream().map(item -> BeanUtil.toBean(item, BizSceneDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:46051_1
        }


        return retData;
    }

    /**
     * D检查集合去除已存在数据[1547]
     * gen by moon at 8/10/2022, 3:17:15 AM
     */
    @Trace(operationName = "D检查集合去除已存在数据")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public CheckCollectionRemoveExistingDataRespDto checkCollectionRemoveExistingData(CheckCollectionRemoveExistingDataReqDto reqDto) {


        CheckCollectionRemoveExistingDataRespDto collectionRemoveExistingDataRes_1 = null;
//步骤0: M-授权权限去除已存在数据（特殊方法） - checkCollectionRemoveExistingData
        //ModelCode: collectionRemoveExistingData
        CheckCollectionRemoveExistingDataRespDto collectionRemoveExistingDataRes = null;
        CheckCollectionRemoveExistingDataReqDto collectionRemoveExistingDataReq = new CheckCollectionRemoveExistingDataReqDto();
        if (reqDto != null) {
            collectionRemoveExistingDataReq.setFrameworkPrivacyList(reqDto.getFrameworkPrivacyList());//sourceId:44297_1
            collectionRemoveExistingDataReq.setPlfAuthList(reqDto.getPlfAuthList());//sourceId:44298_1
        }

        /*M-授权权限去除已存在数据（特殊方法）[1546]  入参两个数据集，通过已存在标识字段匹配，去除第一个数据集中已存在的第二个数据集的数据 */

        collectionRemoveExistingDataRes = nbDivineData.checkCollectionRemoveExistingData(collectionRemoveExistingDataReq);

        collectionRemoveExistingDataRes_1 = collectionRemoveExistingDataRes;

        CheckCollectionRemoveExistingDataRespDto retData = new CheckCollectionRemoveExistingDataRespDto();
        if (collectionRemoveExistingDataRes_1 != null) {
            retData.setFrameworkPrivacyList(collectionRemoveExistingDataRes_1.getFrameworkPrivacyList());//sourceId:44304_1
        }


        return retData;
    }

    /**
     * D授权角色/权限去除已存在[1512]
     * gen by moon at 8/10/2022, 2:34:49 PM
     */
    @Trace(operationName = "D授权角色/权限去除已存在")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public AddCollectionRemoveExistingDataRespDto addCollectionRemoveExistingData(AddCollectionRemoveExistingDataReqDto reqDto) {


        CheckCollectionRemoveExistingDataRespDto collectionRemoveExistingDataRes_1 = null;
//步骤0: M-授权角色/权限去除已存在（特殊方法） - checkCollectionRemoveExistingData
        //ModelCode: collectionRemoveExistingData
        CheckCollectionRemoveExistingDataRespDto collectionRemoveExistingDataRes = null;
        CheckCollectionRemoveExistingDataReqDto collectionRemoveExistingDataReq = new CheckCollectionRemoveExistingDataReqDto();
        if (reqDto != null) {
            collectionRemoveExistingDataReq.setRoleList(reqDto.getRoleList());//sourceId:41013_1
            collectionRemoveExistingDataReq.setRoleIdList(reqDto.getRoleIdList());//sourceId:86274_1
        }

        /*M-授权角色/权限去除已存在（特殊方法）[1511]  入参两个数据集，通过已存在标识字段匹配，去除第一个数据集中已存在的第二个数据集的数据 */

        collectionRemoveExistingDataRes = nbDivineData.checkCollectionRemoveExistingData(collectionRemoveExistingDataReq);

        collectionRemoveExistingDataRes_1 = collectionRemoveExistingDataRes;

        AddCollectionRemoveExistingDataRespDto retData = new AddCollectionRemoveExistingDataRespDto();
        if (collectionRemoveExistingDataRes_1 != null) {
            retData.setRoleList(collectionRemoveExistingDataRes_1.getRoleList());//sourceId:41014_1
        }


        return retData;
    }

    /**
     * D-公共信息存储Redis[1195]
     * gen by moon at 10/2/2022, 12:01:29 AM
     */
    @Trace(operationName = "D-公共信息存储Redis")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public PutPublicInfoToRedisRespDto putPublicInfoToRedis(PutPublicInfoToRedisReqDto reqDto) {


        //步骤0: M-公共信息存储Redis（特殊方法） - putPublicInfoToRedis
        //ModelCode: putPublicInfoToRedis
        PutPublicInfoToRedisRespDto putPublicInfoToRedisRes = null;
        PutPublicInfoToRedisReqDto putPublicInfoToRedisReq = new PutPublicInfoToRedisReqDto();
        if (reqDto != null) {
            putPublicInfoToRedisReq.setUserId(reqDto.getUserId());//SimpleFieldAssign//sourceId:45759_1
            putPublicInfoToRedisReq.setOriginalRoleMemberId(reqDto.getOriginalRoleMemberId());//SimpleFieldAssign//sourceId:45760_1
            putPublicInfoToRedisReq.setInductionRecordId(reqDto.getInductionRecordId());//SimpleFieldAssign//sourceId:45761_1
            putPublicInfoToRedisReq.setRoleCode(reqDto.getRoleCode());//SimpleFieldAssign//sourceId:49844_1
            putPublicInfoToRedisReq.setOrganizationId(reqDto.getOrganizationId());//SimpleFieldAssign//sourceId:45762_1
            putPublicInfoToRedisReq.setHighestOrgID(reqDto.getHighestOrgID());//SimpleFieldAssign//sourceId:200132_1
            putPublicInfoToRedisReq.setDeptId(reqDto.getDeptId());//SimpleFieldAssign//sourceId:45763_1
            putPublicInfoToRedisReq.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:45764_1
            putPublicInfoToRedisReq.setSceneId(reqDto.getSceneId());//SimpleFieldAssign//sourceId:45765_1
            putPublicInfoToRedisReq.setAppId(reqDto.getAppId());//SimpleFieldAssign//sourceId:45766_1
            putPublicInfoToRedisReq.setInductionUnitTypeCode(reqDto.getInductionUnitTypeCode());//SimpleFieldAssign//sourceId:47094_1
            putPublicInfoToRedisReq.setToken(reqDto.getToken());//SimpleFieldAssign//sourceId:49038_1
        }

        /*M-公共信息存储Redis（特殊方法）[1580]  用于用户前端登录成功后，将登录的公共信息缓存到REDIS中 */
        Assert.isNull(putPublicInfoToRedisReq.getHighestOrgID(), "D-公共信息存储Redis-M-公共信息存储Redis（特殊方法）-最高组织ID不能为空", false);
        putPublicInfoToRedisRes = nbDivineData.putPublicInfoToRedis(putPublicInfoToRedisReq);


        PutPublicInfoToRedisRespDto retData = new PutPublicInfoToRedisRespDto();


        return retData;
    }

    /**
     * D1-推送公共字段缓存(公共)[3959]
     * gen by moon at 10/2/2022, 4:39:59 AM
     */
    @Trace(operationName = "D1-推送公共字段缓存(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public PutPublicFieldCacheComRespDto putPublicFieldCacheCom(PutPublicFieldCacheComReqDto reqDto) {


        //步骤0: M1-推送公共字段缓存 - putPublicFieldCache
        //ModelCode: publicFieldCache
        PutPublicFieldCacheRespDto publicFieldCacheRes = null;
        PutPublicFieldCacheReqDto publicFieldCacheReq = new PutPublicFieldCacheReqDto();
        if (reqDto != null) {
            publicFieldCacheReq.setOriginalRoleMemberId(reqDto.getOriginalRoleMemberId());//SimpleFieldAssign//sourceId:203089_1
            publicFieldCacheReq.setUserId(reqDto.getUserId());//SimpleFieldAssign//sourceId:203061_1
            publicFieldCacheReq.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:203062_1
            publicFieldCacheReq.setAppId(reqDto.getAppId());//SimpleFieldAssign//sourceId:203063_1
            publicFieldCacheReq.setCreateInductionId(reqDto.getCreateInductionId());//SimpleFieldAssign//sourceId:317376_1
        }

        /*M1-推送公共字段缓存[3958]  用于定时任务执行时，获取定时任务执行所需的公共信息，存入缓存，供定时任务中虚拟用况使用 */

        publicFieldCacheRes = nbDivineData.putPublicFieldCache(publicFieldCacheReq);


        PutPublicFieldCacheComRespDto retData = new PutPublicFieldCacheComRespDto();


        return retData;
    }

    /**
     * D1查询用户角色缓存Redis列表（特殊方法）(公共)[2189]
     * gen by moon at 8/21/2022, 5:08:39 AM
     */
    @Trace(operationName = "D1查询用户角色缓存Redis列表（特殊方法）(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryUserRoleRedisListComRespDto queryUserRoleRedisListCom(QueryUserRoleRedisListComReqDto reqDto) {


        QueryUserRoleRedisListRespDto getUserRoleListFromRedisRes_1 = null;
//步骤0: M-查用户角色缓存Redis列表（特殊方法） - queryUserRoleRedisList
        //ModelCode: getUserRoleListFromRedis
        QueryUserRoleRedisListRespDto getUserRoleListFromRedisRes = null;
        QueryUserRoleRedisListReqDto getUserRoleListFromRedisReq = new QueryUserRoleRedisListReqDto();
        if (reqDto != null) {
            getUserRoleListFromRedisReq.setOriginalRoleMemberId(reqDto.getOriginalRoleMemberId());//sourceId:64253_1
        }

        /*M-查用户角色缓存Redis列表（特殊方法）[2184]  用于登录时，异步获取登录用户所属的角色信息列表 */

        getUserRoleListFromRedisRes = nbDivineData.queryUserRoleRedisList(getUserRoleListFromRedisReq);

        getUserRoleListFromRedisRes_1 = getUserRoleListFromRedisRes;

        QueryUserRoleRedisListComRespDto retData = new QueryUserRoleRedisListComRespDto();
        if (getUserRoleListFromRedisRes_1 != null) {
            retData.setRoleList(getUserRoleListFromRedisRes_1.getRoleList());//sourceId:64255_1
        }


        return retData;
    }

    /**
     * D1-集合去除已存在员工就职记录数据(公共)[3931]
     * gen by moon at 10/2/2022, 4:29:29 AM
     */
    @Trace(operationName = "D1-集合去除已存在员工就职记录数据(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public AddCollectionRemoveExistingDataComRespDto addCollectionRemoveExistingDataCom(AddCollectionRemoveExistingDataComReqDto reqDto) {


        AddCollectionRemoveExistingDataRespDto collectionRemoveExistingDataRes_1 = null;
//步骤0: M1-集合去除已存在员工就职记录数据 - addCollectionRemoveExistingData
        //ModelCode: collectionRemoveExistingData
        AddCollectionRemoveExistingDataRespDto collectionRemoveExistingDataRes = null;
        AddCollectionRemoveExistingDataReqDto collectionRemoveExistingDataReq = new AddCollectionRemoveExistingDataReqDto();
        if (reqDto != null) {
            collectionRemoveExistingDataReq.setOrgInductionRecordList(reqDto.getOrgInductionRecordList().stream().map(item -> BeanUtil.toBean(item, OrgInductionRecordDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:200291_1
//list-field-assign
            collectionRemoveExistingDataReq.setExistingInductionRecordList(reqDto.getExistingInductionRecordList());//sourceId:200293_1
        }

        /*M1-集合去除已存在员工就职记录数据[3930]  入参两个数据集，通过已存在标识字段匹配，去除第一个数据集中已存在的第二个数据集的数据 */

        collectionRemoveExistingDataRes = nbDivineData.addCollectionRemoveExistingData(collectionRemoveExistingDataReq);


        collectionRemoveExistingDataRes_1 = collectionRemoveExistingDataRes;

        AddCollectionRemoveExistingDataComRespDto retData = new AddCollectionRemoveExistingDataComRespDto();
        if (collectionRemoveExistingDataRes_1 != null) {
            retData.setOrgInductionRecordList(collectionRemoveExistingDataRes_1.getOrgInductionRecordList().stream().map(item -> BeanUtil.toBean(item, OrgInductionRecordDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:200294_1
        }


        return retData;
    }

    /**
     * D1执行接收字段(公共)[4237]
     * gen by moon at 5/21/2024, 2:02:42 AM
     */
    @Trace(operationName = "D1执行接收字段(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public ImplementReceiveFieldComRespDto implementReceiveFieldCom(ImplementReceiveFieldComReqDto reqDto) {


        QueryReceiveFieldDetailRespDto receptionServiceRes_1 = null;
//步骤0: M1-获取接收字段（特殊方法） - queryReceiveFieldDetail
        //ModelCode: receptionService
        QueryReceiveFieldDetailRespDto receptionServiceRes = null;
        QueryReceiveFieldDetailReqDto receptionServiceReq = new QueryReceiveFieldDetailReqDto();
        if (reqDto != null) {
            receptionServiceReq.setOutputNum(reqDto.getOutputNum());//SimpleFieldAssign//sourceId:263242_1
        }

        /*M1-获取接收字段（特殊方法）[3715]  用于特殊方法接收上游入参。 */
        Assert.isNull(receptionServiceReq.getOutputNum(), "D1执行接收字段(公共)-M1-获取接收字段（特殊方法）-传输数值（整数型）不能为空", false);
        receptionServiceRes = nbDivineData.queryReceiveFieldDetail(receptionServiceReq);


        receptionServiceRes_1 = receptionServiceRes;

        ImplementReceiveFieldComRespDto retData = new ImplementReceiveFieldComRespDto();
        if (receptionServiceRes_1 != null) {
            retData.setOutputNum(receptionServiceRes_1.getOutputNum());//SimpleFieldAssign//sourceId:263245_1
        }


        return retData;
    }

    /**
     * D1集合去除已存在的部门数据(公共)[4116]
     * gen by moon at 9/12/2022, 12:27:25 AM
     */
    @Trace(operationName = "D1集合去除已存在的部门数据(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryCollectionRemoveDeptExistingDataListComRespDto queryCollectionRemoveDeptExistingDataListCom(QueryCollectionRemoveDeptExistingDataListComReqDto reqDto) {


        QueryCollectionRemoveDeptExistingDataListRespDto collectionRemoveExistingDataRes_1 = null;
//步骤0: M1查询集合去除已存在的部门数据（特殊方法） - queryCollectionRemoveDeptExistingDataList
        //ModelCode: collectionRemoveExistingData
        QueryCollectionRemoveDeptExistingDataListRespDto collectionRemoveExistingDataRes = null;
        QueryCollectionRemoveDeptExistingDataListReqDto collectionRemoveExistingDataReq = new QueryCollectionRemoveDeptExistingDataListReqDto();
        if (reqDto != null) {
            collectionRemoveExistingDataReq.setDeptList(reqDto.getDeptList());//sourceId:234160_1
            collectionRemoveExistingDataReq.setCollectionRemoveDeptExistingDataList(reqDto.getCollectionRemoveDeptExistingDataList());//sourceId:234161_1
        }

        /*M1查询集合去除已存在的部门数据（特殊方法）[4115]  入参两个数据集，通过已存在标识字段匹配，去除第一个数据集中已存在的第二个数据集的数据 */

        collectionRemoveExistingDataRes = nbDivineData.queryCollectionRemoveDeptExistingDataList(collectionRemoveExistingDataReq);


        collectionRemoveExistingDataRes_1 = collectionRemoveExistingDataRes;

        QueryCollectionRemoveDeptExistingDataListComRespDto retData = new QueryCollectionRemoveDeptExistingDataListComRespDto();
        if (collectionRemoveExistingDataRes_1 != null) {
            retData.setDeptList(collectionRemoveExistingDataRes_1.getDeptList());//sourceId:234165_1
        }


        List<Object> allNodes = new ArrayList<>();
        allNodes.addAll(retData.getDeptList());
        List<TreeNode> nodeList = CommonFunctionHelper.buildTree(allNodes);
        retData.setTreeNode(nodeList);
        retData.setDeptList(null);

        return retData;
    }

    //
}
